package org.csu.mypetstore.api.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.csu.mypetstore.api.vo.ContactDataVO;

import java.util.Date;

@Data
@TableName("contactData")
public class ContactData {
    @TableField(value = "userid")
    private String userId;          //用户名
    @TableField(value = "friendId")
    private String friendId;        //该用户好友的名字
    @TableField(value = "displayName")
    private String displayName;     //好友的显示的名字
    @TableField(value = "avatar")
    private String avatar;          //好友的头像
    @TableField(value = "token")
    private String token;           //显示好友名字首字母
    @TableField(value = "unread")
    private int unread;             //目前未读的消息
    @TableField(value = "lastSendTime")
    private Date lastSendTime;      //与该好友间最后一条消息的时间
    @TableField(value = "lastContent")
    private String lastContent;     //跟好友聊天的最后一句话

    public ContactDataVO toVO(ContactData data){
        ContactDataVO vo = new ContactDataVO();
        vo.setId(data.getFriendId());
        vo.setDisplayName(data.getDisplayName());
        vo.setAvatar(data.getAvatar());
        vo.setIndex(data.getToken());
        vo.setUnread(data.getUnread());
        vo.setLastSendTime(data.getLastSendTime());
        vo.setLastContent(data.getLastContent());

        return vo;
    }
}
